<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/sockjs-client@1/dist/sockjs.min.js"></script>
<script>
    var sock = new SockJS('/socket/api');
    sock.onopen = function () {
        console.log('open');
        sock.send('test');
    };

    sock.onmessage = function (e) {
        console.log('message', e.data);
        sock.close();
    };

    sock.onclose = function () {
        console.log('close');
    };
</script>
</body>
</html>